﻿/*----------------------------------------------------------------------------------------
*
*  Copyright 2019, Gao Hai Hui, <fromzeropoint@126.com>.  All rights reserved.
*  https://gitee.com/helloworldghh/xoskit.git
*  Use of this source code is governed by a MIT license
*  that can be found in the License file.
*
----------------------------------------------------------------------------------------*/
#ifndef __2B50A4DB_1FB8_43c2_9DEF_16B67920B82B__
#define __2B50A4DB_1FB8_43c2_9DEF_16B67920B82B__

#include "../tools/head.h"

/////////////////////////////////////////////////////////////////////////////////////////
// 

namespace xos_box
{
    // 
    // use i_msg
    // 
    class i_thread;
    class i_event;
    class i_msg;

    // 
    // i_callback interface
    // 
    class callback_impl : public xos_stl::mem_item< xos::release_impl< callback_impl >, thread_lock >,
        public i_callback
    {
    public:
        typedef xos::release_impl< callback_impl > T;

    public:
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        //

        static int get_addr( POOL *** pppPool, LIST *** pppList );

    public:
        callback_impl();
        ~callback_impl();

    protected:
        xos::i_thread * m_pThread;
        xos::i_event * m_pEvent;
        bool m_bQuit;
        i_list * m_pList;

    protected:
        static void * thread( void * lpData );
        int run();

    public:
        int init();
        int term();

    public:
		int prior_notify( i_msg *& p );
        int notify( i_msg *& p );
        int size();
    };
}

#endif // __2B50A4DB_1FB8_43c2_9DEF_16B67920B82B__
